<?php
	
	/**
	 * PkController File.
	 * 
	 * @author Brian Bal <brian@youbeqb.com>
	 * @version 1.0
	 * @package pink-koala
	 */
	
	/**
	 * PkController class
	 *
	 * @package pink-koala
	 * @author Brian Bal
	 **/
	
	Abstract Class PkController Extends PkView Implements ArrayAccess
	{
		public $layout;
		public $controller_name = "welcome";
		public $action_name = "index";
		public $view_name = "index";
		
		public function __construct()
		{
			$this->layout = preg_replace("/controller$/", "", strtolower(get_class($this)));
		}
		
		function render($action_name)
		{
			$this->renderView($action_name);
			$this->$action_name();
		}
		
		function renderView($view_name)
		{
			$this->view_name = $view_name;
		}
		
		function redirect($options)
		{
			$href = $this->href($options);
			
			header("Location: $href");
			exit();
		}
		
		function redirectToURL($url)
		{
			header("Location: $url");
			exit();
		}
		
		
		
		
		
		
		// ArrayAccess Implementation
		abstract function index();
		
		function offsetExists($offset)
		{
			return isset($this->$offset);
		}
		
		function offsetGet($offset)
		{
			return $this->get($offset);
		}
		
		function offsetSet($offset, $value)
		{
			$this->$offset = $value;
		}
		
		function offsetUnset($offset)
		{
			unset($this->$offset);
		}
		
	}
	
?>